<template>
	<section>
		<!-- 工具条 -->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.phone" placeholder="手机号"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getUser">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<template>
			<el-table :data="users" highlight-current-row v-loading="loading" style="width: 100%;">
				<el-table-column type="index" label="ID" width="60" >
				</el-table-column>
				<el-table-column prop="nickName" label="姓名" width="120" sortable>
				</el-table-column>
				<el-table-column prop="gender" label="性别" width="90" sortable>
				</el-table-column>
				<el-table-column prop="phone" label="手机号" width="140" sortable>
				</el-table-column>
                <el-table-column prop="openId" label="微信ID" min-width="180" sortable>
				</el-table-column>
                <el-table-column prop="avatarUrl" label="头像" min-width="180" sortable>
					<template slot-scope="scope">
           				<img :src="scope.row.avatarUrl" width="60" @click="showMainImg(scope.row.avatarUrl)" title="点击查看大图" alt="微信头像"/>
					</template>
				</el-table-column>
				<el-table-column prop="collectNumber" label="收藏商品" width="80" sortable>
				</el-table-column>
				<el-table-column prop="recordNumber" label="浏览商品" min-width="80" sortable>
				</el-table-column>
			</el-table>
		</template>

        <!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :page-size="10" :total="total" style="float:right;">
			</el-pagination>
		</el-col>

	</section>
</template>
<script>
	import { getUserListPage } from '../../api/api';
	//import NProgress from 'nprogress'
	export default {
		data() {
			return {
				filters: {
					phone: ''
				},
				loading: false,
				users: [
                ],
                total: 0,
				page: 1,
			}
		},
		methods: {
			//性别显示转换
			// formatSex: function (row, column) {
			// 	return row.sex == 1 ? '男' : row.sex == 0 ? '女' : '未知';
            // },
            handleCurrentChange(val) {
				this.page = val;
				this.getUser();
			},
			//获取用户列表
			getUser: function () {
				let _this = this;
				let para = {
					currentPage: this.page,
					phone: this.filters.phone
				};
				this.listLoading = true;
				//NProgress.start();
				getUserListPage(para).then(function(res){
					//console.log(res);
					_this.total = res.data.data.total;
					_this.users = res.data.data.users;
					_this.listLoading = false;
					//NProgress.done();
				});
			}
		},
		mounted() {
			this.getUser();
		}
	};

</script>

<style scoped>

</style>